package com.anxin.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.anxin.bean.User;
import com.anxin.dao.UserDAO;
import com.anxin.service.UserService;
import com.anxin.util.PageListData;

@Service("userService")
public class UserServiceImpl implements UserService {

	private UserDAO dao;

	@Transactional
	public void save(User user) {
		dao.save(user);
	}

	@Transactional
	public void delete(User user) {
		dao.delete(user);
	}

	@Transactional
	public void delete(Integer id) {
		dao.delete(User.class, id);
	}

	@Transactional
	public void update(User user) {
		dao.update(user);
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	public PageListData queryPage(Map param, int pageNum, int pageSize) {
		param.put("pageNum", pageNum);
		param.put("pageSize", pageSize);
		return dao.queryPage(User.class, param, pageNum, pageSize);
	}

	public User findById(Integer id) {
		return dao.findById(User.class, id);
	}

	public List<User> findAll() {
		return dao.findAll(User.class);
	}

	public User checkLogin(User user) {
		return dao.checkLogin(user);
	}

	@Autowired
	public void setUserDao(UserDAO dao) {
		this.dao = dao;
	}
}
